<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>注册用户</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="css/zhuce.css">
<script type="text/javascript">
		function getfocus(){
					
			document.getElementById("spanId").innerText="";
				
		}	
		
		function losefocus(){
			var uesrnamevalue=document.getElementById("usernameId").value;
			var xmlhttp=new XMLHttpRequest();
			xmlhttp.onreadystatechange = function(){
				if(xmlhttp.readyState==4){
					
					var data=xmlhttp.responseText;
					
					if(data=="true"){
						document.getElementById("spanId").innerText="用户名正确";
					}else{
						document.getElementById("spanId").innerText="用户名已存在";
					}
				}
			
			};
			xmlhttp.open("post","zhucefocus.do",true);
			xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlhttp.send("username="+uesrnamevalue);
			
		}
		
		function jiaoyan(){
			var uesrnamevalue=document.getElementById("usernameId").value;
			var passwordvalue=document.getElementById("passwordId").value;
			var xmlhttp=new XMLHttpRequest();
			xmlhttp.onreadystatechange = function(){
				if(xmlhttp.readyState==4){
					
					var data=xmlhttp.responseText;
					
					if(data=="true"){
						alert("注册成功");
					}else{
						alert("注册失败");
					}
				}
			
			};
			xmlhttp.open("post","zhuce.do",true);
			xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlhttp.send("username="+uesrnamevalue+"&password="+passwordvalue);
		
		}
	</script>

</head>

<body>
	<div class="div_all">

		<%-- <div class="div_1">
				<div style="position: absolute;">
			<c:if test="${username1!=null}">
				<span style="color:red;">用户名: ${username1}</span>
			</c:if>
			<c:if test="${username1==null}">
				<a href="qiehuanUser.do" style="text-decoration: none;color:red;">亲，请登入</a>
			</c:if></div>
			<!-- <div class="div_menu">
				<a href="add_goods_showtype.do" class="a_menu">添加商品 </a>
  				<a href="show_goods.do" class="a_menu">查询商品 </a>
  				<a href="add_type.do" class="a_menu">类别管理 </a>
  				<a href="show_ads.do" class="a_menu">广告维护 </a>
  				<a href="zhuce.jsp" class="a_menu">注册账号 </a>
  				<a href="qiehuanUser.do" class="a_menu">切换账号 </a>
  				<a href="select_orders.do" class="a_menu">订单查询 </a>
  				<a href="go_tongji.do" class="a_menu">销售统计 </a>
			</div> -->
		</div> --%>

		<div class="div_2">

			<div class="zhuce">
				<br />
				<br />
				<br />
				<br /> <span>注册账号:</span><br /> <input type="text" id="usernameId"
					name="username" placeholder="用户名" onblur="losefocus()"
					onfocus="getfocus()" /> <span id="spanId"
					style="font-size:12; margin-left:5px;"></span> <br /> <input
					type="text" name="password" id="passwordId" placeholder="密码" /><br />
				<input type="button" value="注册"
					style="width:80px; margin:30px 300px;" onclick="jiaoyan()" />

			</div>

		</div>
	</div>
</body>
</html>
